<?php
$screen = Blyn::app()->getCurrentNode()->getUIManager()->getCurrentScreen();

?>
<div style="margin-left: 20px">
    <div style="margin-top: 15px">
        <?php
        /** @var BootActiveForm $form */
        $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
            'id' => 'searchForm',
            'type' => 'search',
            'htmlOptions' => array('class' => 'well'),
                ));
        ?>
        <?php echo $form->textFieldRow($model, 'searchText', array('class' => 'input-medium', 'prepend' => '<i class="icon-search"></i>')); ?>        
        <?php
        $ajaxSubmitBtn = $screen->buildAjaxLink('appStoreSearch', 'Search', NULL, NULL, NULL, array('class' => 'btn'));
        ?>
        <?php echo $ajaxSubmitBtn ?>
        <?php $this->endWidget(); ?>        
    </div>
</div>
<div class="well-small" style="margin-left: 10px">
    <?php if ($screen->isAjaxLinkClicked('appStoreSearch')) { ?>
        <?php $apps = $screen->getServiceAppsData(); ?>
        <?php
        if (count($apps) > 0) {
            echo '<table class="table table-hover">';
            foreach ($apps as $id => $name) {
                echo '<tr>';
                echo '<td><strong>App Name:</strong><span class="text-success" style="padding-left:10px"><strong> ' . $name . '</strong></span></td>';
                echo '<td>' . $screen->buildLink('addApp' . $id, '+ Add to service', BUIScreen::LinkType_AjaxLink) . '</td>';
                echo '</tr>';
            }
            echo '</table>';
        } else {
            echo 'not find application.';
        }
        ?>
    <?php } ?>
</div>